<template>
	<view class="padb20">
		<stop isBack>
			<view slot="content">设备保养详情</view>
		</stop>
		<view class="mart3">
			<stab @change="(index)=>{myCurTab=index}" :names="['订单信息','用料情况']"></stab>
		</view>
		<view class="bcf pad3 lh2" v-if="isbool(order)"v-show="myCurTab == 0">
			<view class="list-style-1">基本信息</view>
			<view class="flrc bdbda">
				<view>保养单号:</view>
				<view class="flex1 tar padr3 padtb2 flex-r flex-end">
					{{order.sn}}
				</view>
				<view class="cu-btn sm line-green" @click="copy(order.sn)">复制</view>
			</view>
			<view class="flrc bdbda">
				<view>保养状态:</view>
				<view class="flex1 tar padtb2 flex-r flex-end">
					<status classes="round2" :item="order.status"></status>
				</view>
			</view>
			<view class="flrc bdbda">
				<view>实施员工:</view>
				<view class="flex1 tar padtb2">{{isnull(order.createBy)?'未设置':order.createBy.name}}</view>
			</view>
			<view class="flrc bdbda">
				<view>开始时间:</view>
				<view class="flex1 tar padtb2">{{datetime(order.startAt)}}</view>
			</view>
			<view class="flrc bdbda">
				<view>完成时间:</view>
				<view class="flex1 tar padtb2">{{datetime(order.endAt)}}</view>
			</view>
			<view class="flrc bdbda">
				<view>保养费用:</view>
				<view class="flex1 tar padtb2">{{order.fee}}</view>
			</view>
			<view class="flrc bdbda">
				<view>是否停机:</view>
				<view class="flex1 tar padtb2">{{order.isStop?'是':'否'}}</view>
			</view>
			
			<view class="list-style-1 martb3">保养部位</view>
			<view v-if="isbool(order.pointLog)">
				<view class="bc13 pad2 mart3" v-for="item in order.pointLog">
					<view class="flrc bcf round3 padlr3 pos-r ofh">
						
						<view class="padr2 fs12">
							<text class="fa fa-angle-right"></text>
						</view>
						<view class="">保养项目</view>
						<view class="flex1 tar padtb3 ofe">
							{{item.maintainPoint.name}}
						</view>
						<ripple></ripple>
					</view>
					<view class="padb2 bdw3 bcf">
						<view class="block flex1 tal flex-r flex-start flex-wrap">
							<view @tap="item.note = choice " class="pad2 round "  v-for="choice in item.maintainPoint.choices">
								<view class="padr3 flex1 round padl3 cu-btn"
								:class="choice == item.note?'bg-blue':'line-blue'">
								{{choice}}
								</view>
							</view>
						</view>
					</view>
					<view class="pad2" v-if=" !isnull(item.tips) || !isnull(item.pics)">
						<view>其他信息</view>
						<view class="bdtda mart2" v-if="!isnull(item.tips)">
							{{item.tips}}
							<view v-if="!isbool(item.tips)" class="bcf tac c12">
								<view class="round3 pad3">无备注</view>
							</view>
						</view>
						<view class="bdtda mart2" v-if="isbool(item.pics)">
							<view v-for="picItem in item.pics">
								<image @tap="viewPic(pic(picItem),pics(item.pics))" :src="pic(picItem)" mode="widthFix" class="w100"></image>
							</view>
							<view v-if="item.pics.length == 0" class="bcf tac c12">
								<view class="round3 pad3">无附件图片</view>
							</view>
						</view>
					</view>
				</view>
			</view>
		</view>
		<view class="bcf pad3 bdtso" v-if="myCurTab == 1">
			<view class="tac mar3 pad3 bdda" v-show="items.length == 0">暂无数据</view>
			<view v-for="item in items" class="bdso">
				<store-item class="w100 pad1" :item="item.item"></store-item>
				<view class="w100 bdtdo bc13 flrc pad2">
					<view>使用数量：</view>
					<view class="flex1 tar fwb">{{item.num}}</view>
				</view>
			</view>
		</view>
		<loading :loading="myIsLoading"></loading>
	</view>
</template>

<script>
	import StoreItem from '../../templete/store/store_item.vue'
	export default {
		components:{StoreItem},
		data() {
			return {
				id:0,
				order:{},
				items:[]
			}
		},
		methods: {
			getStoreItemList(){
				this.$api.get('/api/machineParts',{
					_where:{eq:{
						'formOrder.maintainOrder.id':this.id
					}},
					_g:['store','machine']
				},res=>{
					this.items = res.d
				})
			}
		},
		onLoad(option) {
			let id = option.id
			this.id = id
			this.$api.get('/api/machineMaintainOrders/' + id,{},res=>{
				this.log(res)
				this.order = res.d
				this.clearLoading()
				this.getStoreItemList()
			})
		}
	}
</script>

<style>

</style>
